
cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        this._hideAllSlots();
    },

    start () {

    },
    _hideAllSlots(){
        var ad = this.node.getComponent(dragonBones.ArmatureDisplay);
        if (!!ad){
            // cc.log('隐藏插槽:',data);
            let datas = 'XBJ_OfficialHat003;' +
                'XBJ_OfficialHat02;' +
                'XBJ_OfficialHat04;' +
                'XBJ_OfficialHat01;' +
                'XBJ_OfficialHat06;' +
                'XBJ_OfficialHat05;' +
                'XBJ_Flower;' +
                'XBJ_SilkRibbon02;' +
                'XBJ_SilkRibbon01;' +
                'XBJ_Belt';
            var armature = ad.armature();
            var slotNames = datas.split(';');
            for (var i=0;i<slotNames.length;i++){
                let slotName = slotNames[i];
                var slot = armature.getSlot(slotName);//.childArmature = newAd.armature();
                if (slot){
                    slot.visible = false;
                }else{
                    cc.log('未找到插槽:',slotName);
                }
            }
            var slot = armature.getSlot('XBJ_Body');
            slot.displayIndex = 0;

            var slotArm1 = armature.getSlot('XBJ_Arm_R_01');
            slotArm1.displayIndex = 0;
            var slotArm2 = armature.getSlot('XBJ_Arm_L_01');
            slotArm2.displayIndex = 0;

            var slotFoot1 = armature.getSlot('XBJ_Foot_R_01');
            slotFoot1.displayIndex = 0;
            var slotFoot2 = armature.getSlot('XBJ_Foot_L_01');
            slotFoot2.displayIndex = 0;
            // 'XBJ_Foot_R_01;XBJ_Foot_L_01;XBJ_Arm_L_02;XBJ_Arm_R_01;XBJ_Body;XBJ_Flower;XBJ_SilkRibbon02;XBJ_SilkRibbon01\n'
        }else{
            cc.log('节点:'+node.name+'找到龙骨动画组件');
        }
    },
    showHonghua(){
        let datas = 'XBJ_Flower;' +
            'XBJ_SilkRibbon02;' +
            'XBJ_SilkRibbon01';
        var ad = this.node.getComponent(dragonBones.ArmatureDisplay);
        var armature = ad.armature();
        var slotNames = datas.split(';');
        for (var i=0;i<slotNames.length;i++){
            let slotName = slotNames[i];
            var slot = armature.getSlot(slotName);//.childArmature = newAd.armature();
            if (slot){
                slot.visible = true;
            }else{
                cc.log('未找到插槽:',slotName);
            }
        }
    },
    showMaozi(){
        let datas = 'XBJ_OfficialHat003;' +
            'XBJ_OfficialHat02;' +
            'XBJ_OfficialHat04;' +
            'XBJ_OfficialHat01;' +
            'XBJ_OfficialHat06;' +
            'XBJ_OfficialHat05';
        var ad = this.node.getComponent(dragonBones.ArmatureDisplay);
        var armature = ad.armature();
        var slotNames = datas.split(';');
        for (var i=0;i<slotNames.length;i++){
            let slotName = slotNames[i];
            var slot = armature.getSlot(slotName);//.childArmature = newAd.armature();
            if (slot){
                slot.visible = true;
            }else{
                cc.log('未找到插槽:',slotName);
            }
        }

    },
    showYifu(){
        let datas = 'XBJ_Belt';
        var ad = this.node.getComponent(dragonBones.ArmatureDisplay);
        var armature = ad.armature();
        var slotNames = datas.split(';');
        for (var i=0;i<slotNames.length;i++){
            let slotName = slotNames[i];
            var slot = armature.getSlot(slotName);//.childArmature = newAd.armature();
            if (slot){
                slot.visible = true;
            }else{
                cc.log('未找到插槽:',slotName);
            }
        }
        var slot = armature.getSlot('XBJ_Body');
        slot.displayIndex = 1;
        var slotArm1 = armature.getSlot('XBJ_Arm_R_01');
        slotArm1.displayIndex = 1;
        var slotArm2 = armature.getSlot('XBJ_Arm_L_01');
        slotArm2.displayIndex = 1;
    },
    showXiezi(){
        var ad = this.node.getComponent(dragonBones.ArmatureDisplay);
        var armature = ad.armature();
        var slotFoot1 = armature.getSlot('XBJ_Foot_R_01');
        slotFoot1.displayIndex = 2;
        slotFoot1.invalidUpdate();
        var slotFoot2 = armature.getSlot('XBJ_Foot_L_01');
        slotFoot2.displayIndex = 2;
        slotFoot2.invalidUpdate();
    },

    // update (dt) {},
});
